import { GSprite } from "../../../../com/mui/controls/GSprite";
import { Cache } from "../../cache/Cache";
import { MoneyPanel } from "./MoneyPanel";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { StrengthRenderer } from "./StrengthRenderer";
import { ScrollPolicy } from "../../../../fl/controls/ScrollPolicy";
import { ListEvent } from "../../../../fl/events/ListEvent";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ItemData } from "../../resource/info/ItemData";
import { GTileList } from "../../../../com/mui/controls/GTileList";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
//class SpiritEquipBasePanel
    
    export  class SpiritEquipBasePanel extends GSprite
    {
        constructor()
        {
            super();
            return;
        }

        public spiritEquipUpdate(): void
        {
            this.updateAddAttr();
            return;
        }

        public updateMoney(): void
        {
            this._moneyPanel.updateMoney();
            return;
        }

        public updateEquipList(): void
        {
            return;
        }

        public updateAddAttr(): void
        {
            var loc1=Cache.instance.spiritEquip.getEatedSuitNum();
            this._eatAddAttrTxt.htmlText = Cache.instance.spiritEquip.getAddSuitAttrStr(loc1, true);
            return;
        }

        protected /* override */ createDisposedChildrenImpl(): void
        {
            this._rightSprite = new Object /* flash.display.Sprite */();
            this._rightSprite.x = 394;
            this._rightSprite.y = 1;
            this.addChild(this._rightSprite);
            this._moneyPanel = new MoneyPanel();
            this._moneyPanel.x = 16;
            this._moneyPanel.y = 460;
            this.addChild(this._moneyPanel);
            ObjCreate.createBg(0, 0, 321, 480, this._rightSprite);
            ObjCreate.createBg(7, 10, 305, 75, this._rightSprite, ImagesConst.DisabledBg);
            this._tzBitmap = new Object /* flash.display.Bitmap */();
            this._tzBitmap.x = 88;
            this._tzBitmap.y = 94;
            this._rightSprite.addChild(this._tzBitmap);
            this._equipList = ObjCreate.createTileList(12, 116, 310, 320, this._rightSprite);
            this._equipList.columnWidth = 155;
            this._equipList.rowHeight = 63;
            this._equipList.columnCount = 2;
            this._equipList.rowCount = 5;
            this._equipList.setStyle("cellRenderer", StrengthRenderer);
            this._equipList.horizontalScrollPolicy = ScrollPolicy.OFF;
            this._equipList.verticalScrollPolicy = ScrollPolicy.OFF;
            this._equipList.addEventListener(ListEvent.ITEM_CLICK, this.onEquipListClickHandler);
            this._equipList.addEventListener(ListEvent.ITEM_DOUBLE_CLICK, this.onEquipListDoubleClickHandler);
            ObjCreate.createBg(6, 366, 310, 110, this._rightSprite);
            this._eatAddAttrTxt = ObjCreate.createGTextField("", 19, 390, 285, 40, this._rightSprite, GlobalStyle.textFormat6);
            this._eatAddAttrTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._eatAddAttrTxt.wordWrap = true;
            this._eatAddAttrTxt.multiline = true;
            LoaderHelp.addResCallBack(ResFileConst.SpiritEquipStrength, this.onResLoadedHandler);
            return;
        }

        protected onResLoadedHandler(): void
        {
            this._isResLoaded = true;
            ObjCreate.createBitmap(ImagesConst.SpiritEquipLine, 10, 100, this._rightSprite);
            ObjCreate.createBitmap(ImagesConst.SpiritEquipFhtz, 19, 369, this._rightSprite);
            this._tzBitmap.bitmapData = GlobalClass.getBitmapData(ImagesConst.SpiritEquipFhtz);
            return;
        }

        protected clickRightEquipItem(arg1: ItemData, arg2: Boolean=false): void
        {
            return;
        }

        /* internal  */onEquipListClickHandler(arg1: ListEvent): void
        {
            if (arg1.item) 
            {
                this.clickRightEquipItem(arg1.item as ItemData, false);
            }
            return;
        }

        /* internal  */onEquipListDoubleClickHandler(arg1: ListEvent): void
        {
            if (arg1.item) 
            {
                this.clickRightEquipItem(arg1.item as ItemData, true);
            }
            return;
        }

        protected /* var */_rightSprite: Object /* flash.display.Sprite */;

        protected /* var */_moneyPanel: MoneyPanel;

        protected /* var */_tzBitmap: Object /* flash.display.Bitmap */;

        protected /* var */_equipList: GTileList;

        protected /* var */_eatAddAttrTxt: GTextFiled;

        protected /* var */_isResLoaded: Boolean;
    }
